package com.example.smartcity_40.lawyer;

import androidx.appcompat.app.AppCompatActivity;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;

import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.ImageView;
import android.widget.Toast;

import com.example.smartcity_40.Outpatient.bean.StatusBean;
import com.example.smartcity_40.R;
import com.example.smartcity_40.lawyer.apter.UserSeekAdapter;
import com.example.smartcity_40.lawyer.bean.UserSeekBean;
import com.example.smartcity_40.tool.Tool;

import kotlin.Unit;
import kotlin.jvm.functions.Function1;

public class LawyerSeekActivity extends AppCompatActivity {

    private LawyerSeekActivity context;
    private RecyclerView lawyerseeklist;
    private Tool tool;
    private UserSeekAdapter userSeekAdapter;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_lawyer_seek);
        context = this;
        initview();
        seeklaeyermethod();
    }

    private void seeklaeyermethod() {
        Log.e("tag",tool.get("token"));
        tool.send("/prod-api/api/lawyer-consultation/legal-advice/list",
                Tool.GET,
                null,
                true,
                UserSeekBean.class,
                new Function1<UserSeekBean, Unit>() {
                    @Override
                    public Unit invoke(UserSeekBean userSeekBean) {
                        if (userSeekBean.getCode() == 200) {
                            lawyerseeklist.setLayoutManager(new LinearLayoutManager(context));
                            userSeekAdapter.setDate(userSeekBean.getRows());
                            lawyerseeklist.setAdapter(userSeekAdapter);
                        }
                        return null;
                    }
                });
    }

    private void initview() {
        ImageView back = findViewById(R.id.back);
        ImageView add = findViewById(R.id.add);
        lawyerseeklist = findViewById(R.id.lawyerseeklist);
        tool = new Tool(context);
        userSeekAdapter = new UserSeekAdapter(context);

        back.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                context.finish();
            }
        });

        add.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                context.startActivity(new Intent(context,AddLaeyerSeekActivity.class));
            }
        });

    }
}
/*
* 上部显示律师信息，包括头像、名称、从业年限、
咨询人数、法律专长和好评率；下部显示问题信息。内容包括：受理
状态、问题类型、问题描述、上传的图片和联系电话；如果咨询已完
结，则底部显示评价按钮，点击评价按钮页面跳转至服务评价
* */